#include "Core.h"
#include "SyncConnectEvent.h"

SyncConnectEvent::SyncConnectEvent(IMessageSystem::CallBack::OnConnectSuccess s,IMessageSystem::CallBack::OnConnectFailed f,void* ud)
{
	m_SuccessCallback = s;
	m_FailCallback = f;
	m_pUserData = ud;
}

void SyncConnectEvent::SetResult(bool success,IPumpService* svc)
{
	m_bResult = success;
	m_pResultService = svc;
}

void SyncConnectEvent::Handle(IChannelManager* pManager)
{
	if ( pManager )
	{
		if(m_bResult)
		{
			IMessageChannel* mc = pManager->Create(m_pResultService);
			m_SuccessCallback(mc,m_pUserData);
		}
		else
		{
			m_FailCallback(0,m_pUserData);
		}
	}

	delete this;	
}